/******************************************************************************
 *
 * Copyright (c) 2003-2004 PalmSource, Inc. All rights reserved.
 *
 * File: limits
 *
 * Release:
 *
 * Description:
 *
 *
 *****************************************************************************/


#ifndef __PALMSOURCE_CC_HDR_LIMITS
#define __PALMSOURCE_CC_HDR_LIMITS

#include <cfloat>

#ifdef __EXCEPTIONS
#define __THROW(x) throw(x)
#define __NOTHROW() throw()
#else
#define __THROW(x)
#define __NOTHROW()
#endif

namespace std {
	template <class T> class numeric_limits {
	public:
		static const bool is_specialized = false;
		static T min() __NOTHROW();
		static T max() __NOTHROW();
		
		static const int digits = 0;
		static const int digits10 = 0;
		
		static const bool is_signed = false;
		static const bool is_integer = false;
		static const bool is_exact = false;
		
		static const int radix = 0;
		static T epsilon() __NOTHROW();
		static T round_error() __NOTHROW();
		
		static const int min_exponent = 0;
		static const int min_exponent10 = 0;
		static const int max_exponent = 0;
		static const int max_exponent10 = 0;
		
		static const bool has_infinity = false;
		static const bool has_quiet_NaN = false;
		static const bool has_signaling_NaN = false;
		static const float_denorm_style has_denorm = denorm_absent;
		static const bool has_denorm_loss = false;
		static T infinity() __NOTHROW();
		static T quiet_NaN() __NOTHROW();
		static T signaling_NaN() __NOTHROW();
		static T denorm_min() __NOTHROW();
		
		static const bool is_iec559 = false;
		static const bool is_bounded = false;
		static const bool is_modulo = false;
		
		static const bool traps = false;
		static const bool tinyness_before = false;
		static const bool float_round_style round_style = round_toward_zero;
	};

	enum float_round_style {
		round_indeterminate = -1,
		round_toward_zero = 0,
		round_to_nearest = 1,
		round_toward_infinity = 2,
		round_toward_neg_infinity = 3
	};

	enum float_denorm_style {
		denorm_indeterminate = -1,
		denorm_absent = 0,
		denorm_present = 1
	};

	template<> class numeric_limits<bool> {
	public:
		static const bool is_specialized = true;
		static T min() __NOTHROW() { return false; }
		static T max() __NOTHROW() { return true; }
		
		static const int digits = 0;
		static const int digits10 = 0;
		
		static const bool is_signed = false;
		static const bool is_integer = false;
		static const bool is_exact = false;
		
		static const int radix = 0;
		static T epsilon() __NOTHROW();
		static T round_error() __NOTHROW();
		
		static const int min_exponent = 0;
		static const int min_exponent10 = 0;
		static const int max_exponent = 0;
		static const int max_exponent10 = 0;
		
		static const bool has_infinity = false;
		static const bool has_quiet_NaN = false;
		static const bool has_signaling_NaN = false;
		static const float_denorm_style has_denorm = denorm_absent;
		static const bool has_denorm_loss = false;
		static T infinity() __NOTHROW();
		static T quiet_NaN() __NOTHROW();
		static T signaling_NaN() __NOTHROW();
		static T denorm_min() __NOTHROW();
		
		static const bool is_iec559 = false;
		static const bool is_bounded = false;
		static const bool is_modulo = false;
		
		static const bool traps = false;
		static const bool tinyness_before = false;
		static const bool float_round_style round_style = round_toward_zero;
	};

	template<> class numeric_limits<float> {
	public:
		static const bool is_specialized = true;
		static T min() __NOTHROW() { return FLT_MIN; }
		static T max() __NOTHROW() { return FLT_MAX; }
		
		static const int digits = FLT_MANT_DIG;
		static const int digits10 = FLT_DIG;
		
		static const bool is_signed = true;
		static const bool is_integer = false;
		static const bool is_exact = false;
		
		static const int radix = FLT_RADIX;
		static T epsilon() __NOTHROW() { return FLT_EPSILON; }
		static T round_error() __NOTHROW() { return FLT_MAX; } /* wrong */
		
		static const int min_exponent = FLT_MIN_EXP;
		static const int min_exponent10 = FLT_MIN_10_EXP;
		static const int max_exponent = FLT_MAX_EXP;
		static const int max_exponent10 = FLT_MAX_10_EXP;
		
		static const bool has_infinity = true;
		static const bool has_quiet_NaN = true;
		static const bool has_signaling_NaN = false;
		static const float_denorm_style has_denorm = denorm_present;
		static const bool has_denorm_loss = false;
		static T infinity() __NOTHROW() { return 0; } /* wrong */
		static T quiet_NaN() __NOTHROW() { return 0; } /* wrong */
		static T signaling_NaN() __NOTHROW() { return 0; } /* wrong */
		static T denorm_min() __NOTHROW() { return 0; } /* wrong */
		
		static const bool is_iec559 = false;
		static const bool is_bounded = false;
		static const bool is_modulo = false;
		
		static const bool traps = false;
		static const bool tinyness_before = false;
		static const bool float_round_style round_style = round_toward_zero;
	};

}


#endif /* __PALMSOURCE_CC_HDR_LIMITS */
